# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Maintainer: Ray Donnelly <mingw.android@gmail.com>
# Contributor: Saul Ibarra Corretge <saghul@gmail.com>
# Contributor: Frode Solheim <frode@fs-uae.net>

# TODO :: subprocess.Popen .. specifically list2cmdline in subprocess.py
#         needs a fix so it can handle running MSYS2 executables better.
#         Arguments should not be quoted in the Windows fashion as-per:
#         http://www.daviddeley.com/autohotkey/parameters/parameters.htm
#         but instead how Cygwin expects them to be quoted. Checking for
#         {cygwin,msys-2.0}.dll in the executable is the only way that I
#         can think to do this at present.
#         Any double quoted string will cause problems, e.g.
#         -DGNOMELOCALEDIR=\"/mingw64/share/locale\"

_realname=python
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
_pybasever=3.8
pkgver=${_pybasever}.9
pkgrel=2
provides=("${MINGW_PACKAGE_PREFIX}-python3=${pkgver}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3"
           "${MINGW_PACKAGE_PREFIX}-python2<2.7.16-7")
replaces=("${MINGW_PACKAGE_PREFIX}-python3")
pkgdesc="A high-level scripting language (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('PSF')
url="https://www.python.org/"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-expat"
         "${MINGW_PACKAGE_PREFIX}-bzip2"
         "${MINGW_PACKAGE_PREFIX}-libffi"
         "${MINGW_PACKAGE_PREFIX}-mpdecimal"
         "${MINGW_PACKAGE_PREFIX}-ncurses"
         "${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-sqlite3"
         "${MINGW_PACKAGE_PREFIX}-tcl"
         "${MINGW_PACKAGE_PREFIX}-tk"
         "${MINGW_PACKAGE_PREFIX}-zlib"
         "${MINGW_PACKAGE_PREFIX}-xz")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "autoconf-archive")
options=('makeflags') # 'debug' '!strip' )
source=("https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz"
        0000-make-_sysconfigdata.py-relocatable.patch
        0001-fix-_nt_quote_args-using-subprocess-list2cmdline.patch
        0002-restore-setup-config.patch
        0100-MINGW-BASE-use-NT-thread-model.patch
        0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch
        0130-MINGW-configure-MACHDEP-and-platform-for-build.patch
        0140-MINGW-preset-configure-defaults.patch
        0150-MINGW-configure-largefile-support-for-windows-builds.patch
        0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch
        0180-MINGW-init-system-calls.patch
        0200-MINGW-build-in-windows-modules-winreg.patch
        0210-MINGW-determine-if-pwdmodule-should-be-used.patch
        0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch
        0260-MINGW-compiler-enable-new-dtags.patch
        0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch
        0300-MINGW-configure-for-shared-build.patch
        0310-MINGW-dynamic-loading-support.patch
        0330-MINGW-ignore-main-program-for-frozen-scripts.patch
        0350-MINGW-setup-_multiprocessing-module.patch
        0360-MINGW-setup-select-module.patch
        0370-MINGW-setup-_ctypes-module-with-system-libffi.patch
        0380-MINGW-defect-winsock2-and-setup-_socket-module.patch
        0390-MINGW-exclude-unix-only-modules.patch
        0400-MINGW-setup-msvcrt-and-_winapi-modules.patch
        0410-MINGW-build-extensions-with-GCC.patch
        0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch
        0430-MINGW-find-import-library.patch
        0440-MINGW-setup-_ssl-module.patch
        0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch
        0462-MINGW-support-stdcall-without-underscore.patch
        0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch
        0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch
        0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch
        0490-MINGW-customize-site.patch
        0500-add-python-config-sh.patch
        0510-cross-darwin-feature.patch
        0520-py3k-mingw-ntthreads-vs-pthreads.patch
        0530-mingw-system-libffi.patch
        0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch
        0560-mingw-use-posix-getpath.patch
        0565-mingw-add-ModuleFileName-dir-to-PATH.patch
        0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch
        0610-msys-cygwin-semi-native-build-sysconfig.patch
        0620-mingw-sysconfig-like-posix.patch
        0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch
        0640-mingw-x86_64-size_t-format-specifier-pid_t.patch
        0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch
        0660-mingw-use-backslashes-in-compileall-py.patch
        0670-msys-convert_path-fix-and-root-hack.patch
        0690-allow-static-tcltk.patch
        0720-mingw-pdcurses_ISPAD.patch
        0740-grammar-fixes.patch
        0750-builddir-fixes.patch
        0760-msys-monkeypatch-os-system-via-sh-exe.patch
        0770-msys-replace-slashes-used-in-io-redirection.patch
        0800-mingw-install-layout-as-posix.patch
        0810-remove_path_max.default.patch
        0820-dont-link-with-gettext.patch
        0830-ctypes-python-dll.patch
        0840-gdbm-module-includes.patch
        0850-use-gnu_printf-in-format.patch
        0870-mingw-fix-ssl-dont-use-enum_certificates.patch
        0890-mingw-build-optimized-ext.patch
        0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch
        0910-fix-using-dllhandle-and-winver-mingw.patch
        0920-mingw-add-LIBPL-to-library-dirs.patch
        0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch
        0990-MINGW-link-with-additional-library.patch
        1010-install-msilib.patch
        1060-dont-include-system-ncurses-path.patch
        1620-fix-signal-module-build.patch
        1630-build-winconsoleio.patch
        1650-expose-sem_unlink.patch
        1700-cygpty-isatty.patch
        1701-disable-broken-gdbm-module.patch
        1800-link-win-resource-files-and-build-pythonw.patch
        1810-3.7-mpdec-mingw.patch
        1850-disable-readline.patch
        1860-fix-isselectable.patch
        1870-use-_wcsnicmp-instead-wcsncasecmp.patch
        1890-_xxsubinterpretersmodule.patch
        2010-configure-have-inet-pton.patch
        2030-fix-msvc9-import.patch
        2051-set-venv-activate-path-unix.patch
        2052-venv-creation-fixes.patch
        2060-pass-gen-profile-ldflags.patch
        2070-distutils-add-windmc-to-cygwinccompiler.patch
        2080-pkg-config-windows-must-link-ext-with-python-lib.patch
        3000-importlib-bootstrap-path-sep.patch
        3001-pathlib-path-sep.patch
        3011-fix-build-testinternalcapi.patch
        3020-extend-MS_WINDOWS-flag.patch
        4000-clang-arm64.patch
        5000-warnings-fixes.patch
        smoketests.py)

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
  for _patch in "$@"
  do
    msg2 "Applying ${_patch}"
    patch -Nbp1 -i "${srcdir}/${_patch}"
  done
}

del_file_exists() {
  for _fname in "$@"
  do
    if [ -f ${_fname} ]; then
      rm -rf ${_fname}
    fi
  done
}
# =========================================== #

prepare() {
  cd "${srcdir}/Python-${pkgver}"

  plain "Apply Ray Donnelly's should-be-upstreamed patches"
  apply_patch_with_msg \
    0000-make-_sysconfigdata.py-relocatable.patch \
    0001-fix-_nt_quote_args-using-subprocess-list2cmdline.patch \
    0002-restore-setup-config.patch

  plain "Apply Roumen Petrov's core patches (10)"
  apply_patch_with_msg \
    0100-MINGW-BASE-use-NT-thread-model.patch \
    0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch \
    0130-MINGW-configure-MACHDEP-and-platform-for-build.patch \
    0140-MINGW-preset-configure-defaults.patch \
    0150-MINGW-configure-largefile-support-for-windows-builds.patch \
    0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch \
    0180-MINGW-init-system-calls.patch \
    0200-MINGW-build-in-windows-modules-winreg.patch \
    0210-MINGW-determine-if-pwdmodule-should-be-used.patch

  plain "Apply Roumen Petrov's compiler patch (2)"
  apply_patch_with_msg \
    0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch \
    0260-MINGW-compiler-enable-new-dtags.patch

  plain "Apply Roumen Petrov's extensions patches (21)"
  apply_patch_with_msg \
    0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch \
    0300-MINGW-configure-for-shared-build.patch \
    0310-MINGW-dynamic-loading-support.patch \
    0330-MINGW-ignore-main-program-for-frozen-scripts.patch \
    0350-MINGW-setup-_multiprocessing-module.patch \
    0360-MINGW-setup-select-module.patch \
    0370-MINGW-setup-_ctypes-module-with-system-libffi.patch \
    0380-MINGW-defect-winsock2-and-setup-_socket-module.patch \
    0390-MINGW-exclude-unix-only-modules.patch \
    0400-MINGW-setup-msvcrt-and-_winapi-modules.patch \
    0410-MINGW-build-extensions-with-GCC.patch \
    0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch \
    0430-MINGW-find-import-library.patch \
    0440-MINGW-setup-_ssl-module.patch \
    0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch \
    0462-MINGW-support-stdcall-without-underscore.patch \
    0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch \
    0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch \
    0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch \
    0490-MINGW-customize-site.patch

  plain "Apply Ray Donnelly's general/cross patches (42)"
  apply_patch_with_msg \
    0500-add-python-config-sh.patch \
    0510-cross-darwin-feature.patch \
    0520-py3k-mingw-ntthreads-vs-pthreads.patch \
    0530-mingw-system-libffi.patch \
    0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch \
    0560-mingw-use-posix-getpath.patch \
    0565-mingw-add-ModuleFileName-dir-to-PATH.patch \
    0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch

  apply_patch_with_msg \
    0610-msys-cygwin-semi-native-build-sysconfig.patch \
    0620-mingw-sysconfig-like-posix.patch \
    0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch \
    0640-mingw-x86_64-size_t-format-specifier-pid_t.patch \
    0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch \
    0660-mingw-use-backslashes-in-compileall-py.patch \
    0670-msys-convert_path-fix-and-root-hack.patch \
    0690-allow-static-tcltk.patch

  apply_patch_with_msg \
    0720-mingw-pdcurses_ISPAD.patch \
    0740-grammar-fixes.patch \
    0750-builddir-fixes.patch \
    0760-msys-monkeypatch-os-system-via-sh-exe.patch \
    0770-msys-replace-slashes-used-in-io-redirection.patch \
    0800-mingw-install-layout-as-posix.patch \
    0810-remove_path_max.default.patch \
    0820-dont-link-with-gettext.patch \
    0830-ctypes-python-dll.patch \
    0840-gdbm-module-includes.patch \
    0850-use-gnu_printf-in-format.patch \
    0870-mingw-fix-ssl-dont-use-enum_certificates.patch \
    0890-mingw-build-optimized-ext.patch \
    0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch \
    0910-fix-using-dllhandle-and-winver-mingw.patch \
    0920-mingw-add-LIBPL-to-library-dirs.patch \
    0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch \
    0990-MINGW-link-with-additional-library.patch \
    1010-install-msilib.patch \
    1060-dont-include-system-ncurses-path.patch

  plain "New patches added for the update from 3.5.3 to 3.6.1"
  apply_patch_with_msg \
    1620-fix-signal-module-build.patch \
    1630-build-winconsoleio.patch \
    1650-expose-sem_unlink.patch

  # Extend some isatty calls to check for mintty when checking for
  # a terminal output.
  # https://github.com/Alexpux/MINGW-packages/issues/2645
  apply_patch_with_msg \
    1700-cygpty-isatty.patch

  # gdbm is broken and as a result breaks dbm/shelve.
  # Don't include it so the dbm.dumb backend is used instead,
  # like with the official CPython build.
  apply_patch_with_msg \
    1701-disable-broken-gdbm-module.patch

  # https://github.com/Alexpux/MINGW-packages/issues/3139
  apply_patch_with_msg \
    1800-link-win-resource-files-and-build-pythonw.patch

  apply_patch_with_msg \
    1810-3.7-mpdec-mingw.patch \
    1850-disable-readline.patch \
    1860-fix-isselectable.patch \
    1870-use-_wcsnicmp-instead-wcsncasecmp.patch \
    1890-_xxsubinterpretersmodule.patch

  # https://github.com/msys2/MINGW-packages/issues/5184
  apply_patch_with_msg 2010-configure-have-inet-pton.patch

  # https://github.com/msys2/MINGW-packages/issues/5155
  apply_patch_with_msg 2030-fix-msvc9-import.patch

  # https://github.com/msys2/MINGW-packages/issues/5001
  apply_patch_with_msg 2051-set-venv-activate-path-unix.patch
  apply_patch_with_msg 2052-venv-creation-fixes.patch

  apply_patch_with_msg 2060-pass-gen-profile-ldflags.patch
  
  apply_patch_with_msg 2070-distutils-add-windmc-to-cygwinccompiler.patch
  apply_patch_with_msg 2080-pkg-config-windows-must-link-ext-with-python-lib.patch

  # https://github.com/msys2/MINGW-packages/issues/6035
  apply_patch_with_msg 3000-importlib-bootstrap-path-sep.patch
  apply_patch_with_msg 3001-pathlib-path-sep.patch

  apply_patch_with_msg 5000-warnings-fixes.patch

  apply_patch_with_msg 3011-fix-build-testinternalcapi.patch

  apply_patch_with_msg 3020-extend-MS_WINDOWS-flag.patch

  apply_patch_with_msg 4000-clang-arm64.patch

  autoreconf -vfi
}

check() {
  cd "${srcdir}/build-${CARCH}"

  # Some basic tests to ensure nothing major or MSYS2 specific features are
  # broken
  ./python.exe "${srcdir}/smoketests.py"
  MSYSTEM= ./python.exe "${srcdir}/smoketests.py"

  # make test EXTRATESTOPTS="-v"
}

build() {
  local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX})

  if [[ $MINGW_PACKAGE_PREFIX == *-clang-* ]]; then
    export CC=clang CXX=clang++
  fi

  CFLAGS+=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  CXXFLAGS+=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601"
  CPPFLAGS+=" -I${PREFIX_WIN}/include/ncurses "

  declare -a _extra_config
  if check_option "debug" "n"; then
    CFLAGS+=" -DNDEBUG "
    CXXFLAGS+=" -DNDEBUG "
    _extra_config+=("--enable-optimizations")
    _extra_config+=("--with-lto")
  else
    CFLAGS+=" -O0 -ggdb"
    CXXFLAGS+=" -O0 -ggdb"
    _extra_config+=("--with-pydebug")
  fi

  # Workaround for conftest error on 64-bit builds
  export ac_cv_working_tzset=no

  # Workaround for when dlfcn exists on Windows, which causes
  # some conftests to succeed when they shouldn't (we don't use dlfcn).
  export ac_cv_header_dlfcn_h=no
  export ac_cv_lib_dl_dlopen=no
  export ac_cv_have_decl_RTLD_GLOBAL=no
  export ac_cv_have_decl_RTLD_LAZY=no
  export ac_cv_have_decl_RTLD_LOCAL=no
  export ac_cv_have_decl_RTLD_NOW=no
  export ac_cv_have_decl_RTLD_DEEPBIND=no
  export ac_cv_have_decl_RTLD_MEMBER=no
  export ac_cv_have_decl_RTLD_NODELETE=no
  export ac_cv_have_decl_RTLD_NOLOAD=no

  [[ -d "${srcdir}/build-${CARCH}" ]] && rm -rf "${srcdir}/build-${CARCH}"
  mkdir -p "${srcdir}/build-${CARCH}" && cd "${srcdir}/build-${CARCH}"

  MSYSTEM=MINGW ../Python-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --enable-shared \
    --with-nt-threads \
    --with-system-expat \
    --with-system-ffi \
    --with-system-libmpdec \
    --without-ensurepip \
    --without-c-locale-coercion \
    --enable-loadable-sqlite-extensions \
    "${_extra_config[@]}" \
    OPT=""

  # We patch importlib which is embedded in C headers, so regenerate them
  make regen-importlib

  make

  # Add missing venvlauncher files (issue #7014)
  # FIXME: build these from PC/launcher.c instead
  cp python.exe venvlauncher.exe
  cp pythonw.exe venvwlauncher.exe
}

package() {
  cd "${srcdir}/build-${CARCH}"

  local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX})
  MSYSTEM=MINGW \
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  make -j1 install DESTDIR="${pkgdir}"
  if check_option "debug" "n"; then
    VERABI=${_pybasever}
  else
    VERABI=${_pybasever}d
  fi

  # gdb pretty printers for debugging Python itself; to use:
  # python
  # sys.path.append('C:/msys64/mingw64/share/gdb/python3')
  # import python_gdb
  # reload(python_gdb)
  # end
  [[ -d "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/ ]] || mkdir -p "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/
  cp -f python.exe-gdb.py "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/python_gdb.py

  rm "${pkgdir}${MINGW_PREFIX}"/bin/2to3
  cp -f "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/libpython${VERABI}.dll.a "${pkgdir}${MINGW_PREFIX}"/lib/libpython${VERABI}.dll.a

  # Need for building boost python module
  cp -f "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/libpython${VERABI}.dll.a "${pkgdir}${MINGW_PREFIX}"/lib/libpython${_pybasever}.dll.a

  # some useful "stuff"
  install -dm755 "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/{i18n,scripts}
  install -m755 "${srcdir}/Python-${pkgver}"/Tools/i18n/{msgfmt,pygettext}.py "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/i18n/
  install -m755 "${srcdir}/Python-${pkgver}"/Tools/scripts/{README,*py} "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/scripts/

  # clean up #!s
  find "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/ -name '*.py' | \
    xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python|"

  # clean-up reference to build directory
  sed -i "s#${srcdir}/Python-${pkgver}:##" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/Makefile

  for fscripts in 2to3-${_pybasever} idle3 idle${_pybasever} pydoc3 pydoc${_pybasever}; do
    sed -i "s|$(cygpath -w ${MINGW_PREFIX} | sed 's|\\|\\\\|g')/bin/python${_pybasever}.exe|/usr/bin/env python${_pybasever}.exe|g" "${pkgdir}${MINGW_PREFIX}"/bin/${fscripts}
  done

  # Default names are aliases for Python now
  cp "${pkgdir}${MINGW_PREFIX}"/bin/python3.exe "${pkgdir}${MINGW_PREFIX}"/bin/python.exe
  cp "${pkgdir}${MINGW_PREFIX}"/bin/python3w.exe "${pkgdir}${MINGW_PREFIX}"/bin/pythonw.exe
  cp "${pkgdir}${MINGW_PREFIX}"/bin/python3-config "${pkgdir}${MINGW_PREFIX}"/bin/python-config
  cp "${pkgdir}${MINGW_PREFIX}"/bin/idle3 "${pkgdir}${MINGW_PREFIX}"/bin/idle
  cp "${pkgdir}${MINGW_PREFIX}"/bin/pydoc3 "${pkgdir}${MINGW_PREFIX}"/bin/pydoc
  cp "${pkgdir}${MINGW_PREFIX}"/bin/2to3-${_pybasever} "${pkgdir}${MINGW_PREFIX}"/bin/2to3

  sed -i "s|#!${pkgdir}${MINGW_PREFIX}/bin/python${VERABI}.exe|#!/usr/bin/env python${_pybasever}.exe|" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/python-config.py

  # fix permissons
  find ${pkgdir}${MINGW_PREFIX} -type f \( -name "*.dll" -o -name "*.exe" \) | xargs chmod 0755

  # Fix up two instances of MSYS2 paths in python-config.sh in-case the final consumer of the results are native executables.
  sed -e "s|${MINGW_PREFIX}|${PREFIX_WIN}|" \
    -i "${pkgdir}${MINGW_PREFIX}"/bin/python${VERABI}-config \
    -i "${pkgdir}${MINGW_PREFIX}"/bin/python3-config \
    -i "${pkgdir}${MINGW_PREFIX}"/bin/python-config

  # replace paths in sysconfig
  sed -i "s|${pkgdir}${MINGW_PREFIX}|${MINGW_PREFIX}|g" \
    "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/lib-dynload/_sysconfigdata*.py \
    "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/smtpd.py

  # install venv launchers
  mkdir -p "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt
  cp venvlauncher.exe "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt/python.exe
  cp venvwlauncher.exe "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt/pythonw.exe
}

sha256sums=('5e391f3ec45da2954419cab0beaefd8be38895ea5ce33577c3ec14940c4b9572'
            '0ee1acf745d38d41fd098487b9595705fd8f6666d7b154d54ddba32d14f1253b'
            '0d27f52bc514dbf2b730f62fa6c18c797a2f4cbad8698d95b15e2774d68e483d'
            'd2d73d9fb9db48fecb3a6856e4606f444eaac7637fd4f65e192701e53ac422eb'
            'abed03b63e0b498804b44d1cdf8b1ff0c3c4329d3ea9c0323b2512adcacb9b57'
            'c2fb01aacfc5d96bdb69ef37282f300ecd8bfa3e11921caa1fce8e871f5a31f8'
            '6446e0a5255d317d93c5c55094d4c797cf68fbd14bb08d38c94d7080837d1380'
            '8e90c38ac27316781f8853fcbce300526d92732edf4cd08d1dc2a0438fd2d694'
            '36f6e8b4320ee79b6ff7e84aefec3aec57293bcbacf08ea7847f3147d459b4a9'
            '0a6a1ee72f3aa050f1ff0b8ff88845189309163ef1a5f70808f1ab351348cdae'
            '56bdf305a3786ae50871045373e89f2e20df3055e1033197f122ee2c6c8b0966'
            '910c84eb01cfe2207ee7fd8549247d9498be8b58c4dbbb6eaa2118037e77730e'
            'da5057e58a4866e20c3c604153febb2b57a089d327a954ee5b51830af8204e17'
            '265a3c99923b76210e0401bc0cafa88b99328343aec43d64aa94cb84fcdda6d8'
            '4f1db216d6a2dad137b07ccdd4b2d71c37169083706addf90c3b0b850312632a'
            'f07fc8cc9030c2adf9d7c301eadb8b182aad7f1f2cde102cce730f51a093bbdd'
            '9f05613753a8b4ad8c5a6b32c257a318e9ff416345f4ebef3e69f56cf9a51578'
            '9269a4d4dab6a0e93b8a0b5ed84c3e93bdfbaf99148e467daf993f6f767c8d45'
            '1e89597d37838ad7c18463b83476b3cc6bec1480a052e757b9fbfb3264d4d890'
            '03891c0fe4ad90a9926c0e04dc7bb0efbf0022cd6d7746cf2d173dbd739f6142'
            '3b85b18922d21e8fc6e07a12e1c8d79c7ec271dddb75ed0fb4f44148b030b360'
            '6d0119cd216b944927254598cfec1b85757000ab39f5ba987a86ed2216d6351b'
            'ee3f515a3e4060b08b106d788039aa0abfb0424fdf09b613dbab06256405b7ef'
            '9c6e64ba27d72e912be3486a0cc65d9f59f5d7ba71fb634fef0860a00311d12c'
            '3842234d2c3aeece0416a670c789801ef76ce31841a9c1bfcbb26340aa346712'
            '194ef359356d4d58bb15bafe8738c0586350d26e85cc39f5db833f428d67b41d'
            'ce63ec2ec57db5fcfae332f8bb413d6c2f8888d29e449b8ae674cbcbe01a5f95'
            'f7729d39c8eadce379b2b21cd253c604bfe3e4293945b4d6def9bf0c9b3c8f4f'
            '7bd7cac5cc9424b934ae31e6aebf7a960fca8d6ac82778f107a4b16a4e7865c8'
            '85ec670b8c0a8fc7a5dcafc19aa697d358c5bfe67cb3d7e17ec8070d4edb16f3'
            '4804d854bb9fb3e6ff11c23e420b6ff34266bbc93ce33115129bf838171d49ee'
            'a26997445938dd01a03a16a622d19adbc270e679df195407436c97246c96f99a'
            '269fc7d93aeefc286009612604385ac2ec1d0304b97c858ffe123c282be8d94c'
            '17341d1d4f654f8fbaea905dcf0f4091c66eefa6725b592632413fc77498b6c3'
            '47613ba1b262d7c3dbe96ecff5543d0923ad874eec7aa7451e17b0b414691f83'
            '1b3a27ea33b66efe3131dcb9951030aa7d4c18f9ec851e89a4582b69f8e673e7'
            '90719b6f11be4be6e6df37a9699d87da9f5200090baf0276f0d6aeb717b9e06c'
            '840cbf8fafa2cc230dd8a9f667dbad80d54ad573f929f9970252722b9183688b'
            'fbae2e8121a027713ce9cf2197b4d702f512e65d028a2a71d4229a4c70f8410d'
            '95cf0d30ad7f0f171da79187f1564b8b2796e9d76551cfb442c26ae4d9f1aafe'
            '6b37b7d4ecd269abcf92ada988d4be48e0fee1473d6a2cc7d6562812c579095d'
            '4bb617a956b783edfb1a4246580172c4f9eb2728ff14730618854a3be7840dad'
            '65aff7e831f3bb4b37ed5d4db5dfa75ab6bd582d132dd197e658ccb699dbfac7'
            'f2a7b6dce11311e3d318d5729258935a520dcb7ce4dc879ecb1738a2f8bfe434'
            '0a81aa7fd5fa0b511fda81ce3345f3199d3be1c83fc660f7f365ef4ede88f3f7'
            '27122f9db1be8b1efbccd6ab263313aa66c97dfcd0acb9499434a1fa4ecbb2bd'
            '0c93d28bec11968da47b300fe8049d7e32c07c27ccde36ce5f1701306f3cbaf5'
            'cef46c7e1afcaf9b6bacf723d5ae22f3f42045eb93bbd9bf5d2b1dba7638028a'
            '819bd305734a8fe190afdd399e6158c041c5b9912b436375b2d8dc520f7376ba'
            'f33d70071a232a2a3930aa0a2b3f032ef6a17e07acc7412000ceb25bdd339ade'
            '5c56aa13fd3f18bd4b327d8cd540ff7fd9e0145e6358d6330103938655d3dfd7'
            'ca3eea7fac20d160d9aa3a8e17c0b9ab169cfe16a685f78d2c4d1fd52f8f6784'
            '7f2b4c0fcf4a78b983ae3c3a57c47748470370aa4bf17ea9b3ad53802d201afd'
            'a55bd3b222d08dc6bb68d4e30ec3e544b303d93330131a310f3a2e20ca93f4b9'
            '2b4e223aed8ec9df431806c54bd3df923dbd34805e311006aba3f62682eeca56'
            '882d3ac8739184368a30991843db8581e3fd1aee639ddc110ac8cd9e8a89ea1f'
            '5d1a85e93b4c7626aa2cfa68201c2d93574647ab6ef0679d3ff4b4cc5c2ba042'
            'd06065357943599d515b7ea081da99981b68c4c6a9a5e6bb5e0f1019fea80104'
            'b323e44874873591b763b1926cac00d354323d32ff06941eefa415dbdb643cfb'
            '26fe3548c0e3997aa09077a5f4d1b4152c98c6c6e7ed64e26557704cc4758f73'
            '2b33a669fc281b69d6d3683402ea8d83a86f6bf625a14944d0ac553f414688d3'
            '86223efa8b47df1aec5bdecbe5321b29cfbba46e49bf268cf2d646423d8990c2'
            'd817ee8eeb04450de6c313db4cde76cca92236e14b60fb0fdb30014250b76fdb'
            'a8d7416f819963fb7d2e6800d51d27f5fdc74d804d2b559528eb6867c9e3b88a'
            'a492d1366f130122e4e54bee722b65a3d8a2afb30768026e2922edec0d11c9e4'
            '16ab24a074e2e06e6cee4bc06373b2b71e5d7990b71f60fa613a6e9bf55d6c12'
            '3245dc7c2e65e15c981b5a9c6372210dae582e7c7dfee632ec92a40868f3a63b'
            '168172f22ea13879b958179fee20d0b2d78136bc755501f108840a14a0b521f6'
            '5f6de8a7646cf755df9f8666346dbcff1005b5165b7b9aea75921344b3eceee6'
            '84d2457f89057d1f4c48cfe85a1fe4f397eaa6a4f2dd0bad36beccf9dfdb5819'
            '8fe0d9cb7b36faa27d2bb41661f4f9ea0298901d261c5daf702e29e97e46bd4c'
            '7e2652a26a8e7198b9b6fd2bfd476c514362f347ba75b1dd014faac443266fd7'
            '8ea5b335b10bfb4e492646902db043aee06c953941b3eca7fe24603a3238abf8'
            'a9977459a8e6c31f1643da7ede6ac7199dee96559d74188f5c9d3799787ac4fa'
            '7bab1dfb1d5b288e3270a61f9b1892c151f1dd1f8e32c07ae6adc37ef14844bb'
            '551047905350e113384f99e0e929e9381dc0a4ed514ca4ebe279dcdad798edce'
            'afafaa920fee0bb11fb246b37956c71c0e68dadaf09e27ebdcd7097dd2c0f0ef'
            'fc6164a90f0ca2a9341aaf4448b4334c3393459ca5cbad6d7149f8bcf70da5fe'
            '181672743d9e2449064a1b18764fa400af5d3cd268098e7b7e5069d0b128caa2'
            '6f2032347bb40e2ebe9b3a03062147ffa2f656d47c87821623c3b7d46dc15ddb'
            'c4670070e546317295071350872e1a00918fd3284609620f84beb44ed54c1ebd'
            '17bf1ea04f476ee66555bc4386ffbebfe6be6f75e67947b7f85511241ac46407'
            '0ded9e2792b95902d898aba91020103875f2987a9566b353f3e6988b08848f4a'
            'd3a0669c83e4df5d33606b4c3443d2c6c71b76cb4f6421d6d54ee630023be6c2'
            'a7fbf65a86889f95138360ca4dbd4e51de2e214384ee39740d9c6c381ff997d9'
            'ac0400fd7c9ceada1356fe4b7eae3892f35652f09f488b31fd011e0642d373a3'
            '6f1a48380445406709ba5c6b4b9c6f0301ea645324feb429f3719dc29b8f28ff'
            'b2f4083ada35c18876edf38220d84ca757cf710bc5c2d80ee8b5083dc6c2609f'
            '487c92837717975ad6c63fe2a1f8e8c5c9e0554e96000102d83c82f4a77fd9bd'
            'f6ecf2edc9468210111d77e396853af49cb8a43d9bc0d20212f88cf2bc33685d'
            '6efc39323d14239f2a55576a8b3f32cb79eeefdd5881ba813493c14be2939f3c'
            '005381222cfef42ccc21151845b6d43d25c861f35c2192e5e23c2a14df7938f0'
            'b6b3f8f2c809dc7ef43bc26306516edf4a5d1e038343ad8c7a45f666011c2e8b'
            '717167e9ca5563e04103871a3e489dd1cef77a83c5c6d20e7bda6dced7f3fc42'
            '24151631c3e70306ae92ffb8fea38992a752cd0a76771a5e53445f56c2be1f00'
            '7188e017a1efba4a87cb64a38b63ed2d8a469e2e74c3fd35b6538d5bc6e370e5')
